package utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import dao.UserDao;
import model.User;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DBUtil {
    private static DataSource ds=new ComboPooledDataSource();
    public static DataSource getDataSource()
    {
        return  ds;
    }
    public static Connection getConnection() throws SQLException {
        return ds.getConnection();
    }
    public static void main(String[] args) throws SQLException {
        System.out.println(DBUtil.getConnection());
        User user=new User();
        user.setUsername("lijiayin");
        user.setEmail("2480243521@qq.com");
        user.setName("李佳音");
        user.setPhone("17612937572");
        user.setAddress("陕西省渭南市");
        UserDao userDao=new UserDao();
        userDao.addUser(user);
    }
}
